package com.jt.controller;

import com.jt.pojo.MemberCard;
import com.jt.service.MemberCardService;
import com.jt.vo.PageResult;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/member")
public class MemberCardController {

    @Autowired
    private MemberCardService memberCardService;

    //会员卡服务列表展示
    @GetMapping("/getMemberCardList")
    public SysResult  getMemberCardList(PageResult pageResult){
        pageResult = memberCardService.getMemberCardList(pageResult);
        return SysResult.success(pageResult);
    }

    //会员卡类型新增
    @PostMapping("/addMemberCard")
    public SysResult addMemberCard(@RequestBody MemberCard memberCard){
        memberCardService.addMemberCard(memberCard);
        return SysResult.success();
    }

    //会员卡类型修改
    @GetMapping("/{id}")
    public SysResult getMemberCard(@PathVariable Integer id){
      MemberCard memberCard =   memberCardService.getMemberCard(id);
      return SysResult.success(memberCard);
    }
    @PutMapping("/updatedMemberCard")
    public SysResult updatedMemberCard(@RequestBody MemberCard memberCard){
        memberCardService.updatedMemberCard(memberCard);
        return SysResult.success();
    }

    //会员卡类型删除
    @DeleteMapping("/{id}")
    public SysResult deleteMemberCard(@PathVariable Integer id){
        memberCardService.deleteMemberCard(id);
        return SysResult.success();
    }

}
